package com.sky.mapper;

import com.sky.entity.DishFlavor;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface DishFlavorMapper {

    /**
     * 插入菜品风味到菜品风味表
     * @param dishFlavor
     */
    @Insert("insert dish_flavor(dish_id, name, value) " +
            "values (#{dishId}, #{name}, #{value})")
    @Options(useGeneratedKeys = true, keyProperty = "id")
    void save(DishFlavor dishFlavor);

    /**
     * 根据菜品id从菜品风味表删除菜品风味信息
     * @param dishId
     */
    @Delete("delete from dish_flavor where dish_id = #{dishId}")
    void delByDishId(long dishId);

    /**
     * 根据菜品id从菜品风味表查询菜品风味信息
     * @param lid
     * @return
     */
    @Select("select id, dish_id, name, value from dish_flavor " +
            "where dish_id = #{dishId}")
    List<DishFlavor> getByDishId(Long lid);
}
